package com.ruoyi.user.controller;

import com.repair.api.user.request.param.UserQueryParam;
import com.repair.api.user.request.param.UserUpdateStatusParam;
import com.repair.api.user.response.data.UserInfo;
import com.repair.base.result.JsonResult;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.user.service.AdminUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * @author chunyu
 * @since 2024/9/27,21:09
 */
@Api(tags = "保修人员模块")
@RestController
@RequestMapping("/admin/user")
public class AdminUserController {

    @Autowired
    private AdminUserService adminUserService;


    /*获取全部用户信息（分页）*/
    @ApiOperation("查询全部保修人员")
    @PreAuthorize("@ss.hasPermi('system:AllUser:index')")
    @GetMapping("/getAllUserInfo")
    public R<TableDataInfo> getAllUsers(UserQueryParam userQueryParam) {
        TableDataInfo tableDataInfo = adminUserService.getAllUsers(userQueryParam);
        return R.ok(tableDataInfo);
    }

    /*查询用户详细信息（前台）*/
    @GetMapping("/selectUserInfoById")
    public R<UserInfo> selectUsersById(Long id) {
        UserInfo userInfo = adminUserService.selectUsers(id);
        return R.ok(userInfo);
    }

    @ApiOperation("拉黑/取消拉黑 用户")
    @PostMapping("/blockOrUnBlockUsers")
    public R<Boolean> blockOrUnBlockUsers(@RequestBody UserUpdateStatusParam param) {
        Boolean result = adminUserService.blockOrUnBlockUsers(param);
        return R.ok(result);
    }








    // ----------------------------------------------许宁------------------------------------------------------------------------







    /*用户等级信息*/

    /*拉黑用户BlockUser*/
    @PostMapping("/update/state/{id}/{state}")
    public R<UserInfo> updateState(@PathVariable Long id, @PathVariable String state) {
        adminUserService.updateState(id, state);
        return R.ok();
    }

    /*查询全部拉黑用户BlockUser*/
    // 忽略这个方法
    @GetMapping("/selectBlockUserInfoById")
    public JsonResult<UserInfo> selectBlockUserById(Long id) {
//        adminUserService.selectBlockUser(id);
        return null;
    }





}
